#include <bits/stdc++.h>
using namespace std;
using LL = long long;

// #define zerol
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)

#ifdef zerol
#define dbg(x...)                             \
    do                                        \
    {                                         \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err()
{
    cerr << "\033[39;0m" << endl;
}
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x)
{
    for (auto v : a)
        cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x)
{
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif

const int N = 2e5 + 50;

int n;

vector<int> a[N];
vector<int> b[N];

struct Dsu {
    int f[N];

    void init(int n = N-1) {
        for (int i=0; i<=n; ++i) {
            f[i] = i;
        }
    }

    inline int find(int x) {
        return f[x] == x ? x : (f[x]=find(f[x]));
    }

    void connect(int x, int y) {
        f[find(x)] = find(y);
    }


} ds;

struct P3 {
    int x, y, z;
    P3(int x=0, int y=0, int z=0):x(x) ,y(y), z(z) {}
};
int main()
{
    scanf("%d", &n);
    dbg(n);
    for (int i = 1; i <= n; ++i)
    {
        int sz;
        scanf("%d", &sz);
        dbg(i, sz);
        a[i].reserve(sz);
        int x;
        for (int j = 0; j < sz; ++j)
        {
            scanf("%d", &x);
            a[i].push_back(x);
        }
    }
    vector<int> disc;
    {
        for (int i = 1; i <= n; ++i)
        {
            for (int x : a[i])
                disc.push_back(x);
        }
        sort(disc.begin(), disc.end());
        disc.resize(unique(disc.begin(), disc.end()) - disc.begin());

        for (int i=1; i<=n; ++i) {
            for (int &x : a[i])
                x = lower_bound(disc.begin(), disc.end(), x) - disc.begin();
        }
    }

    for (int i=1; i<=n; ++i) {
        for (int x : a[i])
            b[x].push_back(i);
    }
    for (int x : disc)
        dbg(x);
    ds.init(n);
    vector<P3> ans;
    ans.reserve(n-1);
    int m = (int)disc.size();
    for (int i=0; i<m; ++i) {
        int sz = (int)b[i].size();
        for (int j=0; j<sz-1; ++j) {
            int x = b[i][j], y = b[i][j+1];
            x = ds.find(x);
            y = ds.find(y);
            if (x != y) {
                ds.connect(x, y);
                ans.emplace_back(b[i][j], b[i][j+1], disc[i]);
            }
        }
    }
    if ((int)ans.size() < n-1) {
        puts("impossible");
        return 0;
    }
    for (const auto &p : ans) {
        printf("%d %d %d\n", p.x, p.y, p.z);
    }

    


    return 0;
}